﻿using System.Web.Mvc;
using AutoMapper;
using BusinessLayer;
using ShopKart.Areas.User.Models;
using ShopKart.Controllers;

namespace ShopKart.Areas.User.Controllers
{
    public class ProductController : BaseController
    {
        // GET: User/Product
        public ActionResult Index()
        {
            return View();
        }

        // GET: User/Product/Products?categoryId
        public ActionResult Products(long? categoryId)
        {
            ProductManager productManager = new ProductManager();
            ProductVm productVm = new ProductVm()
            {
                Products = productManager.GetByCategory(categoryId.Value)
            };
            return View("Products", productVm);
        }

        public ActionResult ProductDetail(long? productId)
        {
            ProductManager productManager = new ProductManager();
            var product = productManager.GetById(productId.Value);
            ProductVm productVm = Mapper.Map<ProductVm>(product);
           
            return View( productVm);
        }
    }
}